# Database层 - 数据库连接池和ORM

# 源文件
set(DATABASE_SOURCES
    mysql_pool.cpp
    mysql_helper.cpp
    mysql_orm.cpp
    redis_pool.cpp
    database_config.cpp
    database_health.cpp
)

# 头文件
set(DATABASE_HEADERS
    connection_pool.h
    mysql_pool.h
    mysql_helper.h
    mysql_orm.h
    redis_pool.h
    database_config.h
    database_health.h
)

# 创建database库
add_library(database STATIC
    ${DATABASE_SOURCES}
    ${DATABASE_HEADERS}
)

target_include_directories(database PUBLIC
    ${CMAKE_SOURCE_DIR}
    /usr/include/mysql-cppconn-8
    /usr/include/hiredis
)

target_link_libraries(database PUBLIC
    logger
    config  # 依赖config模块
    nlohmann_json::nlohmann_json
    pthread
    mysqlcppconn
    hiredis
)

# 设置编译选项
target_compile_features(database PUBLIC cxx_std_17)

# 添加编译定义（如果需要）
target_compile_definitions(database PUBLIC
    -DMYSQL_ENABLED
    -DREDIS_ENABLED
)

# 测试程序
add_executable(test_database test_database.cpp)
target_link_libraries(test_database PRIVATE
    database
    config  # 测试需要config模块
    logger
    nlohmann_json::nlohmann_json
    mysqlcppconn
    pthread
)
